app.controller("brandController", function($scope,brandService,$controller) {
    $controller("baseController",{$scope:$scope})
    $scope.findAll=function(){
        brandService.findAll().success(
            function(data){
                $scope.list=data;
            }
        );
    };
    //创建一个方法
    $scope.findByPage = function(currentPage,itemsPerPage){
        brandService.findByPage(currentPage,itemsPerPage).success(function(data){
            $scope.paginationConf.totalItems = data.totals;
            $scope.list = data.rows;

        }) };
    $scope.save = function(){
        var object = null;
        if($scope.entity.id != null){
            object = brandService.updateBrand($scope.entity)
        }else{
            object = brandService.save($scope.entity)
        }
        object.success(function(data){
            if(data.success){
                $scope.reloadList();
            }else{
                alert(data.message);
            }
        })
    }
    $scope.findById = function(number){

        brandService.findById(number).success(
            function(data){
                $scope.entity = data;
            }
        )
    }
    //批量删除
    $scope.delete=function(){
        //获取选中的复选框
        brandService.delete($scope.selectIds).success(
        function(response){
                if(response.success){
                    $scope.reloadList();//刷新列表
                    $scope.selectIds=[];
                }
            }
        );
    }
    $scope.searchEntity = {};
    $scope.search = function(currentPage,itemsPerPage){
        brandService.search(currentPage,itemsPerPage,$scope.searchEntity).success(function(data){
            $scope.paginationConf.totalItems = data.totals;
            $scope.list = data.rows;
        }) };



});